//
//  NSDataExtension.swift
//  multimeter
//
//  Created by 强建龙 on 17/7/27.
//  Copyright © 2017年 chinake. All rights reserved.
//

import Foundation

extension NSData {
    func hexedString() -> String {
        var string = String()
        let unsafePointer = bytes.assumingMemoryBound(to: UInt8.self)
        for i in UnsafeBufferPointer<UInt8>(start:unsafePointer, count: length) {
            string += Int(i).hexedString()
        }
        return string
    }
    
//    func MD5() -> NSData {
//        let result = NSMutableData(length: Int(CC_MD5_DIGEST_LENGTH))!
//        let unsafePointer = result.mutableBytes.assumingMemoryBound(to: UInt8.self)
//        CC_MD5(bytes, CC_LONG(length), UnsafeMutablePointer<UInt8>(unsafePointer))
//        return NSData(data: result as Data)
//    }
}
